package com.yuandian.management.controller;

import com.yuandian.bpm.common.core.util.R;
import com.yuandian.management.service.FlowAlarmConfService;
import com.yuandian.management.service.FlowConfService;
import com.yuandian.management.service.FlowOriginalDataFilterConfigService;
import com.yuandian.management.vo.flow.FlowOriginalDataFilterConfig;
import com.yuandian.management.vo.flow.alarm.AlarmHotConfig;
import com.yuandian.management.vo.flowConf.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;

/**
 * flink任务读取配置
 *
 * @author lsx
 * @date 2023-6-1
 */
@Api(tags = "")
@RestController
@RequestMapping("/flow/conf")
public class FlowConfController {

	@Autowired
	private FlowConfService flowConfService;

	@Autowired
	private FlowAlarmConfService flowAlarmConfService;

	@Autowired
	private FlowOriginalDataFilterConfigService flowOriginalDataFilterConfigService;

	/**
	 * 区域配置信息
	 *
	 * @return Result
	 */
	@GetMapping("/areaConf")
	public R<AreaConf> getAreaConf() {
		return R.ok(flowConfService.getAreaConf());
	}

	/**
	 * 营业厅配置
	 * <营业厅编号, 区域编码>
	 *
	 * @return Result
	 */
	@GetMapping("/businessHallConf")
	public R<BusinessHallConf> getBusinessHallConf() {
		return R.ok(flowConfService.getBusinessHallConf());
	}

	/**
	 * 渠道配置信息
	 *
	 * @return Result
	 */
	@GetMapping("/channelMappingConf")
	public R<ChannelMappingConf> getChannelMappingConf() {
		return R.ok(flowConfService.getChannelMappingConf());
	}

	/**
	 * 已确认的业务服务资源配置
	 * <加工拼接后的资源编码, 占位符无意义>
	 *
	 * @return Result
	 */
	@GetMapping("/confirmedResourceConf")
	public R<ConfirmedResourceConf> getConfirmedResourceConf() {
		return R.ok(flowConfService.getConfirmedResourceConf());
	}

	/**
	 * db端系统组件关系配置
	 * <组件ip十进制格式, [系统端组件的关系配置信息]>
	 *
	 * @return Result
	 */
	@GetMapping("/dbIpSegmentComRelationConf")
	public R<IpSegmentComRelationConf> getDbIpSegmentComRelationConf() {
		return R.ok(flowConfService.getIpSegmentComRelationConf(Collections.singletonList("DB")));
	}

	/**
	 * mid端系统组件关系配置
	 * <组件ip十进制格式, [系统端组件的关系配置信息]>
	 *
	 * @return Result
	 */
	@GetMapping("/midIpSegmentComRelationConf")
	public R<IpSegmentComRelationConf> getMidIpSegmentComRelationConf() {
		return R.ok(flowConfService.getIpSegmentComRelationConf(Collections.singletonList("MID")));
	}

	/**
	 * 详单组合配置信息
	 *
	 * @return Result
	 */
	@GetMapping("/detailConf")
	public R<DetailConf> getDetailConf() {
		return R.ok(flowConfService.getDetailConf());
	}


	/**
	 * 操作员配置信息
	 * <操作员编号, 操作员实体>
	 *
	 * @return Result
	 */
	@GetMapping("/employeeConf")
	public R<EmployeeConf> getEmployeeConf() {
		return R.ok(flowConfService.getEmployeeConf());
	}

	/**
	 * 专属指标配置信息
	 *
	 * @return Result
	 */
	@GetMapping("/exclusiveIndicatorConf")
	public R<ExclusiveIndicatorConf> getExclusiveIndicatorConf() {
		return R.ok(flowConfService.getExclusiveIndicatorConf());
	}


	/**
	 * 描述: 系统组件关系配置
	 * <ip, IT端与组件关系映射集合>
	 *
	 * @return Result
	 */
	@GetMapping("/ipSegmentComRelationConf")
	public R<IpSegmentComRelationConf> getIpSegmentComRelationConf() {
		return R.ok(flowConfService.getIpSegmentComRelationConf(null));
	}

	/**
	 * 描述: 模块配置
	 *
	 * @return Result
	 */
	@GetMapping("/moduleConf")
	public R<ModuleConf> getModuleConf() {
		return R.ok(flowConfService.getModuleConf());
	}

	/**
	 * 描述: 步骤sessionId回填专属指标配置
	 * <首端业务资源编码, <GET/SAVE, 专属指标code>>
	 *
	 * @return Result
	 */
	@GetMapping("/sessionIdFillBackConf")
	public R<SessionIdFillBackConf> getSessionIdFillBackConf() {
		return R.ok(flowConfService.getSessionIdFillBackConf());
	}

	/**
	 * 描述: 步骤顺序配置
	 * key = 步骤编码
	 * value = sequence
	 *
	 * @return Result
	 */
	@GetMapping("/stepSequenceConf")
	public R<StepSequenceConf> getStepSequenceConf() {
		return R.ok(flowConfService.getStepSequenceConf());
	}

	/**
	 * 系统-业务-步骤配置
	 * <systemId|resourceCode, 系统-业务-步骤配置>
	 *
	 * @return Result
	 */
	@GetMapping("/systemBusiStepRelationConf")
	public R<SystemBusiStepRelationConf> getSystemBusiStepRelationConf() {
		return R.ok(flowConfService.getSystemBusiStepRelationConf());
	}

	/**
	 * 业务服务资源发现黑名单配置
	 * <过滤字符串值小写/大写字母标识, 1>
	 *
	 * @return Result
	 */
	@GetMapping("/webFilterConf")
	public R<WebFilterConf> getWebFilterConf() {
		return R.ok(flowConfService.getWebFilterConf());
	}

	/**
	 * 描述: web和step端的系统组件关系配置
	 * <网端端类型(step或web), <ip, IT端与组件关系映射集合>>
	 *
	 * @return Result
	 */
	@GetMapping("/webStepIpSegmentComRelationConf")
	public R<WebStepIpSegmentComRelationConf> getWebStepIpSegmentComRelationConf() {
		return R.ok(flowConfService.getWebStepIpSegmentComRelationConf());
	}

	/**
	 * 描述: 白名单配置
	 * <白名单类型, 白名单列表>
	 *
	 * @return Result
	 */
	@GetMapping("/whiteListConf")
	public R<WhiteListConf> getWhiteListConf() {
		return R.ok(flowConfService.getWhiteListConf());
	}

	/**
	 * 网端与业务服务资源存在配置
	 * <segmentId|resourceCode, true>
	 *
	 * @return Result
	 */
	@GetMapping("/segmentResourceExistConf")
	public R<SegmentResourceExistConf> getSegmentResourceExistConf() {
		return R.ok(flowConfService.getSegmentResourceExistConf());
	}

	/**
	 * 实时流参数配置
	 *
	 * @return Result
	 */
	@GetMapping("/flowParamsConf")
	public R<FlowParamsConf> getFlowParamsConf() {
		return R.ok(flowConfService.getFlowParamsConf());
	}


	/**
	 * 基础告警配置
	 *
	 * @return
	 */
	@GetMapping("/getAlarmConfigEntityConfig")
	public R<AlarmHotConfig> getAlarmConfigEntityConfig() {

		return R.ok(flowAlarmConfService.getAlarmConfigEntityConfig());
	}

	/**
	 * 原始数据包捕获功能
	 *
	 * @return
	 */
	@GetMapping("/queryOriginalDataFilterList")
	public R<FlowOriginalDataFilterConfig> queryOriginalDataFilterList() {
		return R.ok(flowOriginalDataFilterConfigService.queryOriginalDataFilterList());
	}

	/**
	 * 原始数据包捕获规则配置信息2
	 *
	 * @return Result
	 */
	@GetMapping("/getOriDataFilterConf")
	public R<OriDataFilterConf> getOriDataFilterConf() {
		return R.ok(flowConfService.getOriDataFilterConf());
	}


	/**
	 * network agent
	 *
	 * @return Result
	 */
	@GetMapping("/getNetworkAgentMap")
	public R<NetworkAgentConf> getNetworkAgentMap() {
		return R.ok(flowConfService.getNetworkAgentMap());
	}

}
